package com.health.life;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.health.life.enty.CookClass;

import java.util.List;

/**
 * Created by tukela on 2015/7/1.
 */
public class ClassAdapter extends BaseAdapter {
    private final List<CookClass> cookClassList;
    private final LayoutInflater mInflater;

    public ClassAdapter(Context context,List<CookClass> cookClassList){
        this.cookClassList=cookClassList;
        mInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public int getCount() {
        return cookClassList.size();
    }

    @Override
    public Object getItem(int position) {
        return cookClassList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CookClass cookClass=cookClassList.get(position);
        if (convertView == null) {
            convertView = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
        }

        TextView header = (TextView)convertView;
        header.setText(cookClass.getName());
        return convertView;
    }
}
